<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" ng-app="redash" ng-controller='MainCtrl'> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" ng-app="redash" ng-controller='MainCtrl'> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" ng-app="redash" ng-controller='MainCtrl'> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" ng-app="redash" ng-controller='MainCtrl'> <!--<![endif]-->
<head>
    <base href="{{base_href}}">
    <title ng-bind="'{{name}} | ' + pageTitle"></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <!-- build:css /styles/main.css -->
    <link rel="stylesheet" href="/bower_components/bootstrap/dist/css/bootstrap.css">
    <link rel="stylesheet" href="/bower_components/codemirror/lib/codemirror.css">
    <link rel="stylesheet" href="/bower_components/gridster/dist/jquery.gridster.css">
    <link rel="stylesheet" href="/bower_components/pivottable/dist/pivot.css">
    <link rel="stylesheet" href="/bower_components/cornelius/src/cornelius.css">
    <link rel="stylesheet" href="/bower_components/angular-ui-select/dist/select.css">
    <link rel="stylesheet" href="/bower_components/pace/themes/pace-theme-minimal.css">
    <link rel="stylesheet" href="/bower_components/font-awesome/css/font-awesome.css">
    <link rel="stylesheet" href="/bower_components/codemirror/addon/hint/show-hint.css">
    <link rel="stylesheet" href="/bower_components/leaflet/dist/leaflet.css">
    <link rel="stylesheet" href="/styles/redash.css">
    <!-- endbuild -->

    <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
    <link rel="icon" type="image/png" sizes="96x96" href="/images/favicon-96x96.png">
    <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">

</head>
<body{% if headless %} class="headless"{% endif %}>
<div growl></div>

{% block content %}
{% endblock %}

<div ng-view></div>
<div ng-if="showPermissionError" class="ng-cloak container" ng-cloak>
    <div class="row">
        <div class="text-center">
            <h1><span class="glyphicon glyphicon-lock"></span></h1>
            <p class="text-muted">
                You do not have permission to view the requested page.
            </p>
        </div>
    </div>
</div>

{% if not headless %}
{% raw %}
<div class="visible-print">
  <hr>
  Source: {{location}}
</div>
{% endraw %}
{% include 'footer.html' %}
{% endif %}

{% include 'vendor_scripts.html' %}

<!-- build:js({.tmp,app}) /scripts/scripts.js -->
<script src="/scripts/app.js"></script>
<script src="/scripts/services/services.js"></script>
<script src="/scripts/services/resources.js"></script>
<script src="/scripts/services/notifications.js"></script>
<script src="/scripts/services/dashboards.js"></script>
<script src="/scripts/controllers/controllers.js"></script>
<script src="/scripts/controllers/dashboard.js"></script>
<script src="/scripts/controllers/admin_controllers.js"></script>
<script src="/scripts/controllers/data_sources.js"></script>
<script src="/scripts/controllers/query_view.js"></script>
<script src="/scripts/controllers/query_source.js"></script>
<script src="/scripts/controllers/users.js"></script>
<script src="/scripts/visualizations/base.js"></script>
<script src="/scripts/visualizations/chart.js"></script>
<script src="/scripts/visualizations/cohort.js"></script>
<script src="/scripts/visualizations/map.js"></script>
<script src="/scripts/visualizations/counter.js"></script>
<script src="/scripts/visualizations/boxplot.js"></script>
<script src="/scripts/visualizations/box.js"></script>
<script src="/scripts/visualizations/table.js"></script>
<script src="/scripts/visualizations/pivot.js"></script>
<script src="/scripts/visualizations/date_range_selector.js"></script>
<script src="/scripts/directives/directives.js"></script>
<script src="/scripts/directives/query_directives.js"></script>
<script src="/scripts/directives/data_source_directives.js"></script>
<script src="/scripts/directives/dashboard_directives.js"></script>
<script src="/scripts/filters.js"></script>
<script src="/scripts/controllers/alerts.js"></script>
<!-- endbuild -->

<script>
    // TODO: move currentUser & features to be an Angular service
    var clientConfig = {{ client_config|safe }};
    var basePath = "{{base_href}}";
    var currentUser = {{ user|safe }};

    currentUser.canEdit = function(object) {
        var user_id = object.user_id || (object.user && object.user.id);
        return this.hasPermission('admin') || (user_id && (user_id == currentUser.id));
    };

    currentUser.hasPermission = function(permission) {
        return this.permissions.indexOf(permission) != -1;
    };

    currentUser.isAdmin = currentUser.hasPermission('admin');
</script>
{% include '_includes/tail.html' %}

</body>
</html>
